package com.zsyh.changshang.util;

import android.annotation.SuppressLint;
import android.graphics.Color;
import android.os.CountDownTimer;
import android.widget.Button;


/**
 * Created by Administrator on 2016/11/3.
 */
public class TimeTextLogin extends CountDownTimer {
    private Button mBtn;

    public TimeTextLogin(long millisInFuture, long countDownInterval, Button btn) {
        super(millisInFuture, countDownInterval);//参数依次为总时长,和计时的时间间隔
        this.mBtn = btn;
    }

    @Override
    public void onTick(long millisUntilFinished) {
        mBtn.setClickable(false);
        mBtn.setBackground(null);
        mBtn.setText(millisUntilFinished / 1000 + "s后重新获取");
        mBtn.setTextColor(Color.parseColor("#999999"));
    }

    @SuppressLint("ResourceAsColor")
    @Override
    public void onFinish() {
        mBtn.setText("获取验证码");
        mBtn.setBackground(null);
        mBtn.setTextColor(Color.parseColor("#2DCFAB"));
        mBtn.setClickable(true);
    }
}
